<%@ page language="java" contentType="text/html; charset=UTF-8"%>

<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp" %>

<form name="form1" id="form1" action="${systemctx}/sample/saveSample.web" method="post">
	<input type="hidden" name="errorPage" value="/systemmanage/user/v001" />
	<input type="hidden" id="userId" name="userId" value="" />
	<input type="hidden" id="idStr" name="idStr"/>
	<input type="hidden" id="rowNumStr" name="rowNumStr"/>
	
	<div class="pageMain">
	<div class="pageTitle">
	<%=MessageResourcesUtils.getMessage(request, "systemmanage.bascsetting.title") %><span></span>
	<%=MessageResourcesUtils.getMessage(request, "systemmanage.usermaintain.title") %><span></span>
	<%=MessageResourcesUtils.getMessage(request, "systemmanage.usermaintainlist.title") %>
	</div>
	<div class="pageBody">
 
	<div class="form-group">
		<ul>
			<li>
				<i></i>
				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.authority.list.loginname") %></label>
				<span><input type="text" class="input-sm" id="username" name="username" value="" /></span>
			</li>
			<li>
				<i></i>
				<label><%=MessageResourcesUtils.getMessage(request, "systemmanage.authority.list.checkstatus") %></label>
				<span><select id="checkstatus" name="checkstatus"></select></span>
			</li>
		</ul>
	</div>	
	</div>
	<div class="button-group">
		<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
		<input type="button" class="btn btn-default" onclick="userAdd()" value="<%=MessageResourcesUtils.getMessage(request, "common.button.add") %>" />
	</div>
	<br />
	<table width="100%">
	<tbody>
		<tr>
			<td>
				<table id="datagrid"></table>
			</td>
		</tr>
	</tbody>
	</table>
	</div>
</form>

<script type="text/javascript">	
 
$(document).ready(function() {
	$("#butUpdatePasw").click(function(){
		var ids = getIds();
		if (ids != '' && ids != undefined) {
			if(confirm('<%=MessageResourcesUtils.getMessage(request, "systemmanage.user.spassword.update.confoirm")%>')){
				showSending();
				$.ajax({
					type : 'POST',
					url : '${systemctx}/systemmanage/user/sendMail.web',
					data : $("#form1").serialize(),
					dataType : 'json',
					success : function(data) {
						//关闭执行...
						closeSending();
						$.fn.ajaxmessage(data);
					}
				});
			}
		}
	});
	
	
	//加载Select控件 qmodule
	$("#checkstatus").selectutil({
		optModel : <%=SysConstant.CheckStatus.getModelJSONString(true,false)%>
	});
	//加载分页控件 datagrid
	$('#datagrid').issdatagrid({
			title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.usermaintainlist.title") %>',
			width: 'auto',
			nowrap: true,
			autoRowHeight: false,
			striped: true,
			//collapsible:true,
			url:'${systemctx}/user/queryUserListInfoDataGrid.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			remoteSort: true,
			idField:'id',
			pagination:true,
			rownumbers:true,
			queryParams:$('#form1').serializeObject(),
			columns:[[
			          /* {field:'ck', checkbox:true}, */
			    {
					field : 'id',
					title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation") %>',
					width : 60,
					align : 'center',
					formatter : operate
				},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.usercode") %>', field:'userno', width:120, sortable:true},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.userloginname") %>', field:'loginname', width:120, sortable:true},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.username") %>', field:'username', width:120, sortable:true},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.validstart") %>', field:'validstart', width:120, sortable:true,align:'center'},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.validend") %>', field:'validend', width:120, sortable:true,align:'center'},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.inputuser") %>', field:'inputname', width:120, sortable:true},
				{title:'<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.status") %>', field:'checkstatus', width:120, sortable:true,align:'center'},
				{field:'status', hidden:true}
			]],
			onLoadSuccess : function(data){

			}
	});
 
	
	$('#butQuery').click(function (){
		$('#datagrid').datagrid('load', 
				$('#form1').serializeObject()
			);
	});
	
	function operate(val, row) {
		return '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="fnModify('+ val
		+ ')"><%=MessageResourcesUtils.getMessage(request, "common.button.update") %></a> ';
	}
	
});

function getIds() {
	var ids = "";
	var rows = $('#datagrid').datagrid('getChecked');
	if (rows.length == 0) {
		messageAlert("<%=MessageResourcesUtils.getMessage(request, "dailyoperation.selects.warning")%>");
		return;
	} else {
		for (var i = 0; i < rows.length; i++) {
			ids += rows[i].id + ",";
		}
		if (ids != '') {
			ids = ids.substring(0,ids.length - 1);
		}
		return ids;
	}
}

function comfrim(a)
{
	messageComfrim("<%=MessageResourcesUtils.getMessage(request, "alertinfo.common.jsp.alert2") %>","userDelete("+a+")");
}

function userAdd() {
	$(this).isswindow({
		title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.title") %>',
		noheader : true,
		url : '${systemctx}/systemmanage/user/toAddUser.web'
	});
}

function userDelete(val) {
	var id = val;
	//正在执行...
	showSending();
	$.ajax({
		type : 'GET',
		url : '${systemctx}/systemmanage/user/deleteUser.json?id='+id,
		dataType : 'json',
		success : function(data) {
			//关闭执行...
			closeSending();
			if(data.message == "删除成功"){
				//显示AJAX请求后的提示信息
				$.fn.ajaxmessage(data);
				$('#datagrid').datagrid('reload',$('#form1').serializeObject());
				$('#datagrid').datagrid('clearSelections');
			}else if(data.message != "删除成功"){
				$.fn.ajaxmessage(data);
			}
		}
	});
}

function fnModify(id){
	$(this).isswindow({
		title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.User.add.title") %>',
		noheader : true,
		url : '${systemctx}/systemmanage/user/toUpdateUser.web?userid='+id
	});
}
 
</SCRIPT>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp" %>